package zsh

import (
	

	
)

type namedDirectories map[string]string

// NamedDirectories provides rudimentary named directory support as these aren't expanded by zsh in the `${words}` provided to the compdef function
var NamedDirectories = make(namedDirectories)

func ( *namedDirectories) ( string) string {
	if strings.HasPrefix(, "~") && !strings.HasPrefix(, "~/") && strings.Contains(, "/") {
		return NamedDirectories[strings.SplitN(, "/", 2)[0][1:]]
	}
	return ""
}

// Matches checks if given string has a known named directory prefix
func ( *namedDirectories) ( string) bool {
	return .match() != ""
}

// Replace replaces a known named directory prefix with the actual folder
func ( *namedDirectories) ( string) string {
	if  := .match();  != "" {
		if !strings.HasSuffix(, "/") {
			 =  + "/"
		}
		return  + strings.SplitN(, "/", 2)[1]
	}
	return 
}

func init() {
	if  := env.Hashdirs();  != "" {
		for ,  := range strings.Split(, "\n") {
			if  := strings.SplitN(, "=", 2); len() == 2 {
				NamedDirectories[[0]] = [1]
			}
		}
	}
}